<template>
  <div>
    <basic-container>
      <avue-crud
        ref="scopeTree"
        :data="tableData"
        :option="option"
        :page="page"
        :destroy-on-close="true"
        @refresh-change="searchHandler"
        @on-load="onLoad"
        @search-change="searchChange"
      >
        <template slot-scope="scope" slot="menu">
          <el-button
            @click="drawerOpen(scope.row)"
            icon="el-icon-arrow-right"
            size="small"
            type="text"
            >查看审批过程</el-button
          >
        </template>
      </avue-crud>
    </basic-container>
    <el-drawer
      title="审批过程"
      :visible.sync="drawer"
      :direction="rtl"
      :before-close="handleClose"
      append-to-body="true"
      :destroy-on-close="true"
    >
      <innovativeDrawer
        :reviewId="reviewId"
        :isApprovue="false"
        :type="60"
      ></innovativeDrawer>
    </el-drawer>
  </div>
</template>
<script>
import { getInnovativeUndertaking } from "@/api/teacherPage/innovativeUndertaking";
import { baseUrl } from "@/config/env";
import innovativeDrawer from "@/components/reviewDrawer/innovativeDrawer";

export default {
  components: {
    innovativeDrawer
  },
  name: "",
  data() {
    return {
      reviewId: "",
      drawer: false,
      page: {
        pageSize: 10,
        total: 10
      },
      headers: {
        Authorization: ""
      },
      searchForm: {
        currentPage: 1,
        pageSizes: 10
      },
      tableData: [],
      option: {
        border: true,
        index: true,
        indexLabel: "序号",
        stripe: true,
        menuAlign: "center",
        editBtn: false,
        delBtn: false,
        addBtn: false,
        viewBtn: this.getPermission("innovativeUndertaking_get"),
        searchMenuSpan: 6,
        align: "center",
        column: [
          {
            label: "姓名",
            prop: "name",
            search: true,
            searchLabelWidth: 45,
          },
          {
            label: "学号",
            prop: "studentKey",
            search: true,
          },
          {
            label: "班级",
            prop: "classStr",
            search: true,
            type: "select",
            props: {
              label: "className",
              value: "id",
            },
            dicUrl: `${baseUrl}/pc/stu-class/byName`,
          },
          {
            label: "学期",
            display: false,
            prop: "termId",
            type: "select",
            remote: true,
            props: {
              label: "term",
              value: "id"
            },
            dicUrl: `${baseUrl}/pc/term/all`,
            rules: [
              {
                required: true,
                message: "学期不能为空",
                trigger: "blur"
              }
            ]
          },
          {
            label: "类型",
            prop: "type",
            dicData: [
              {
                label: "2+1创业班",
                value: 10
              },
              {
                label: "申请完成互联网+项目",
                value: 20
              },
              {
                label: "申请成功创业园项目",
                value: 30
              },
              {
                label: "自主创新创业认定",
                value: 40
              }
            ]
          }
        ]
      }
    };
  },
  methods: {
    searchChange(params, done){
       console.log(params);
       this.searchForm.classId = params.classStr
       this.searchForm.studentKey = params.studentKey
       this.searchForm.name = params.name
       this.searchHandler();
       done()
    },
    searchHandler() {
      getInnovativeUndertaking(this.searchForm).then(res => {
        this.page.pageSizes = res.data.pageSizes;
        this.page.total = res.data.total;
        this.tableData = res.data.records;
      });
    },
    onLoad(page) {
      this.searchForm.currentPage = page.currentPage;
      this.searchForm.pageSize = page.pageSize;
      this.searchHandler();
    },
    drawerOpen(res) {
      console.log(res);
      this.reviewId = res.flowId;
      this.drawer = true;
    }
  }
};
</script>
